package priv.wangy.micro.common.constant;

import lombok.Getter;
import priv.wangy.micro.common.po.http.rspn.BaseListRspn;

import java.util.Arrays;

/**
 * @author zhangjq
 * @since 2024-05-13
 */
@Getter
public enum InstKindEnum {
    GOV_OFC("10", "机关", InstKind.GovOfc.class),
    PUB_INST("20", "事业单位", InstKind.PubInst.class),
    ENTERPRISE("30", "企业", InstKind.Enterprise.class),
    TROOP("40", "部队"),
    SOC_INST("50", "社会组织机构"),
    INT_INST("60", "国际组织机构"),
    NAT_DEF_INST("70", "国防科工机构"),
    FI_INST("80", "财政金融机构"),
    OTHER("99", "其他");

    public interface InstKind {

        BaseListRspn.Field.Property getProperty();

        enum GovOfc implements InstKind {
            BELOW_PROV {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("11", "省级以下党政机关");
                }
            },
            ABOVE_PROV {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("12", "省级以上党政机关");
                }
            }
        }

        enum PubInst implements InstKind {
            RES_DES {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("21", "科研设计单位");
                }
            },
            HIGH_EDU {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("22", "高等学校");
                }
            },
            OTHER_EDU {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("23", "其他教育单位");
                }
            },
            MED_HEAL {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("24", "医疗卫生单位");
                }
            },
            SPORT_CULT {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("25", "体育文化单位");
                }
            },
            OTHER {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("29", "其他事业单位");
                }
            }
        }

        enum Enterprise implements InstKind {
            STATE {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("31", "国有企业");
                }
            },
            SINO_FOREIGN {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("32", "中外合资企业");
                }
            },
            PRIVATE {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("33", "民营（私营）企业");
                }
            },
            FOREIGN {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("34", "外资企业");
                }
            },
            COLLECTIVE {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("35", "集体企业");
                }
            },
            OTHER {
                @Override
                public BaseListRspn.Field.Property getProperty() {
                    return new BaseListRspn.Field.Property("39", "其他企业");
                }
            }
        }
    }

    private final String value;

    private final String display;

    private final InstKind[] instKinds;

    InstKindEnum(String value, String display) {
        this.value = value;
        this.display = display;
        this.instKinds = null;
    }

    InstKindEnum(String value, String display, Class<? extends InstKind> instKinds) {
        this.value = value;
        this.display = display;
        this.instKinds = instKinds.getEnumConstants();
    }

    public static final BaseListRspn.Field FIELD = new BaseListRspn.Field("COMPANY_QUALITY", Arrays.asList(
            InstKind.GovOfc.ABOVE_PROV.getProperty(),
            InstKind.GovOfc.BELOW_PROV.getProperty(),
            InstKind.PubInst.RES_DES.getProperty(),
            InstKind.PubInst.HIGH_EDU.getProperty(),
            InstKind.PubInst.OTHER_EDU.getProperty(),
            InstKind.PubInst.MED_HEAL.getProperty(),
            InstKind.PubInst.SPORT_CULT.getProperty(),
            InstKind.PubInst.OTHER.getProperty(),
            InstKind.Enterprise.STATE.getProperty(),
            InstKind.Enterprise.SINO_FOREIGN.getProperty(),
            InstKind.Enterprise.PRIVATE.getProperty(),
            InstKind.Enterprise.FOREIGN.getProperty(),
            InstKind.Enterprise.COLLECTIVE.getProperty(),
            InstKind.Enterprise.OTHER.getProperty(),
            new BaseListRspn.Field.Property(TROOP.getValue(), TROOP.getDisplay()),
            new BaseListRspn.Field.Property(SOC_INST.getValue(), SOC_INST.getDisplay()),
            new BaseListRspn.Field.Property(INT_INST.getValue(), INT_INST.getDisplay()),
            new BaseListRspn.Field.Property(NAT_DEF_INST.getValue(), NAT_DEF_INST.getDisplay()),
            new BaseListRspn.Field.Property(FI_INST.getValue(), FI_INST.getDisplay()),
            new BaseListRspn.Field.Property(OTHER.getValue(), OTHER.getDisplay())));
}
